<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>

<link href="../css/sys.css" type="text/css" rel="stylesheet" />
	<script src="../js/jquery-3.2.1.js"></script>
	<script>
		$.ajax({
			url:"studentpage",
			type:"post",
			success:function (result) {
				var studentList = result.list;
                var pages = result.pages;
                var pageNum = result.pageNum;
                var isFirstPage = result.isFirstPage;
                var isLastPage = result.isLastPage;
				for (var i in studentList){
					var student = studentList[i];
					addNewTR(student);
				}
                $("#pages").append("<a id='up'>[上一页]</a>")

                for (var i = 1; i < pages+1; i++) {
                    if (i == pageNum) {
                        $("#pages").append("<a id=" + i + "; class='current_page'; onclick='changePage(" + i + ")'>[" + i + "]</a>")
                    } else {
                        $("#pages").append("<a id=" + i + "; onclick='changePage(" + i + ")'>[" + i + "]</a>")
                    }
                }
                $("#pages").append("<a id='down'>[下一页]</a>")
                if (!isFirstPage) {
                    var num = pageNum - 1;
                    $("#up").attr("onclick", "changePage(" + num + ")");
                }
                if (!isLastPage) {
                    var num = pageNum + 1;
                    $("#down").attr("onclick", "changePage(" + num + ")");
                }
			}
		})
        function changePage(pagenum) {
            $.ajax({
                url: "studentpage",
                type: "post",
                data: {
                    pageNo: pagenum,
                },
                success: function (result) {
                    $("#body").empty();
                    $("#pages").empty();
                    var studentList = result.list;
                    var pages = result.pages;
                    var pageNum = result.pageNum;
                    var isFirstPage = result.isFirstPage;
                    var isLastPage = result.isLastPage;
                    for (var i in studentList) {
                        var student = studentList[i];
                        addNewTR(student);
                    }
                    $("#pages").append("<a id='up'>[上一页]</a>")
                    if (!isFirstPage) {
                        var num = pageNum - 1;
                        $("#up").attr("onclick", "changePage(" + num + ")");
                    }
                    for (var i = 1; i < pages+1; i++) {
                        if (i == pageNum) {
                            $("#pages").append("<a id=" + i + "; class='current_page'; onclick='changePage(" + i + ")'>[" + i + "]</a>")
                        } else {
                            $("#pages").append("<a id=" + i + "; onclick='changePage(" + i + ")'>[" + i + "]</a>")
                        }
                    }
                    $("#pages").append("<a id='down'>[下一页]</a>")
                    if (!isLastPage) {
                        var num = pageNum + 1;
                        $("#down").attr("onclick", "changePage(" + num + ")");
                    }
                }
            })
        }
		function addNewTR(student) {
			$("#body").append("<tr><td align='center'>"+student.name+"("+student.gender+")</td>" +
					"<td align='center'>"+student.admissiontime+"</td><td align='center'>"+student.aClass.name+"</td>" +
					"<td align='center'>"+student.qq+"</td><td align='center'>"+student.telephone+"</td>" +
                    "<td align='center'>"+student.actualtuition+"/"+student.musttuition+"</td>" +
                    "<td align='center'>"+student.status+"</td>" +
					"<td align='center'><a href='editstudent'><img src='../images/button/modify.gif' class='img'/></a></td>" +
					"<td align='center'><a href='editstation'><img src='../images/button/modify.gif' class='img'/></a></td>" +
					"<td align='center'><a href='showstudent'><img src='../images/button/view.gif' class='img'/></a></td>" +
					"<td align='center'><a href='addrunoff'><img src='../images/button/modify.gif' class='img'/></a></td></tr>");
		}
	</script>
</head>

<body >

 <table border="0" cellspacing="0" cellpadding="0" width="100%">
  <tr>
    <td class="topg"></td>
  </tr>
</table>

<table border="0" cellspacing="0" cellpadding="0"  class="wukuang"width="100%">
  <tr>
    <td width="1%"><img src="../images/tleft.gif"/></td>
    <td width="39%" align="left">[在校学生管理]</td>
   
    <td width="57%"align="right">
    	<%--查询 --%>
		<a href="javascript:void(0)" onclick="document.forms[0].submit();"><img src="../images/button/gaojichaxun.gif" /></a>
    	<%--添加 --%>
    	<a href="../pages/student/addOrEditStudent.jsp">
    		<img src="../images/button/tianjia.gif" />
    	</a>
    </td>
    <td width="3%" align="right"><img src="../images/tright.gif"/></td>
  </tr>
</table>

<!-- 查询条件：添加或选择马上查询 -->
<form action="../pages/student/listStudent.jsp" method="post">
	<table width="88%" border="0" style="margin: 20px;" >
	  <tr>
	    <td width="80px">查询条件：</td>
	    <td width="300px"><input type="text" name="condition" size="20" value=""/>（姓名|电话|QQ|性别）</td>
	    <td width="500px">
	    	课程类别：
	    	<select name="crmClass.crmCourseType.courseTypeId" onchange="">
			    <option value="">--选择班级--</option>
			    <option value="ee050687bd1a4455a153d7bbb7000008">JavaEE</option>
			    <option value="ee050687bd1a4455a153d7bbb7000009">大数据</option>
			</select>

	    	班级：<select name="crmClass.classId" >
				    <option value="">----请--选--择----</option>
				</select>
	    </td>
	    <td></td>
	  </tr>
	</table>
</form>


<table border="0" cellspacing="0" cellpadding="0" style="margin-top:5px;">
  <tr>
    <td ><img src="../images/result.gif"/></td>
  </tr>
</table>
<table width="100%" border="1" >
  
	<thead>
  <tr class="henglan" style="font-weight:bold;">
    <td width="10%" align="center">姓名</td>
    <td width="10%" align="center">入学时间</td>
    <td width="10%" align="center">班级</td>
    <td width="10%" align="center">QQ</td>
    <td width="10%" align="center">联系电话</td>
    <td width="10%" align="center">已付/应付学费</td>
    <td width="10%" align="center">状态</td>  <!-- 新生、转班、升级、退费、毕业 -->
  	<td width="5%" align="center">编辑</td>
  	<td width="5%" align="center">升级/转班</td>
  	<td width="5%" align="center">查看</td>
  	<td width="5%" align="center">流失</td>
  </tr>
	</thead>
	<tbody id="body">
	</tbody>
</table>
 <div id="pages" style="text-align: center">

 </div>
</body>
</html>